package com.njtoyo.taxi.admin.rest.controller.business.operation_rule;


import cn.hutool.core.lang.Dict;
import com.njtoyo.taxi.admin.rest.wrapper.business.operation_rule.relation_number.RelationNumberAddUpdateWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.operation_rule.relation_number.RelationNumberBindWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.operation_rule.start_price.StartPriceAddUpdateWrapper;
import com.njtoyo.taxi.admin.service.business.RelationNumberService;
import com.taxi.entity.common.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 隐私号码管理
 */
@RestController
@RequestMapping("/business/operation-rule/privacy-number")
public class RelationNumberController {
    @Autowired
    private RelationNumberService relationNumberService;

    @RequestMapping("/page")
    public RestResult page(@RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
                           @RequestParam(value = "size", required = false, defaultValue = "15") Integer size,
                           @RequestParam(value = "driverRegionId",required = false) String driverRegionId,
                           @RequestParam(value = "mobileNumber",required = false) String mobileNumber) {
        return relationNumberService.page(current, size,driverRegionId,mobileNumber);
    }

    @PostMapping("/add")
    public RestResult add(@RequestBody @Validated RelationNumberAddUpdateWrapper wrapper) {
        return relationNumberService.add(wrapper);
    }

    @PostMapping("/update")
    public RestResult update(@RequestBody @Validated RelationNumberAddUpdateWrapper wrapper) {
        return relationNumberService.update(wrapper);
    }


    @PostMapping("/switchIsActive")
    public RestResult switchIsActive(@RequestBody Dict dict) {
        Long id = dict.getLong("id");
        Boolean isActive = dict.getBool("isActive");
        return relationNumberService.switchIsActive(id, isActive);
    }

    @PostMapping("/bind")
    public RestResult bind(@RequestBody @Validated RelationNumberBindWrapper wrapper) {
        return relationNumberService.bind(wrapper);
    }
}
